|
|
|
|
|
|
|
readability of your code. To further the trend of commenting your application, you should have a brief comment box at the beginning of each procedure and function to describe what the item does (but not how). Any arguments passed to the procedure should be described when their usage isn't obvious or when a certain range of values is expected. |
|
|
|
|
|
|
|
|
You've probably also read about the need for naming conventions. In a Visual Basic application, every object, constant, and variable needs to have a well thought-out name. Each name should include a prefix that defines the data type it's defined as. For example, strFirstname tells any programmer that the variable is defined as a string and that it's used to hold the first name for a data entry. |
|
|
|
|
|
|
|
|
To show you how all this helps, the earlier sample code has been rewritten with all these conventions: |
|
|
|
|
|
|
|
|
Private Sub cmdSaveRecord_Click()
********
* This routine will check to see if the person being added to
* the database is already there. If it is not on the database then
* it will complete the ADDNEW function by issuing an UPDATE against
* the database.
*
* The variable vntBookMrk is used to pass the pointer to the current
* record.
* The variable intNoRecords is used to inform the calling routine if the
* Record was found or not.
*
*********
Screen.MousePointer = VBHourglass
* If this is a new entry check to see if it already exists
If cmdNewEntry.Enabled = False Then
Set recLogRecord = dbLogBook.CreateDynaset(cdt_tbl)
recLogRecord.FindFirst [first name] = & txtFirstName & _
and [last name] = & txtLastName &
If Not recLogRecord.NoMatch Then
recLogRecord.Close
Screen.MousePointer = VBDefault
MsgBox Duplicate Candidate Name Entered, VBExclamation, _ App.Title
txtFirstName.SetFocus
Exit Sub
End If
recLogRecord.Close
End If
* If no records were found set intNoRecords to True
If datLogEntry.Recordset.EOF And datLogEntry.Recordset.BOF Then
intNoRecords = True
Else
vntBookMrk = datLogEntry.Recordset.BookMark
intNoRecords = False
|
|
|
|
|
|